package cn.tedu.jewelry.controller;

import cn.tedu.jewelry.entity.Brand;
import cn.tedu.jewelry.mapper.BrandMapper;
import cn.tedu.jewelry.restful.JsonResult;
import cn.tedu.jewelry.vo.BrandStandVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BrandController {
    @Autowired(required = false)
    BrandMapper brandMapper;

    //获取品牌列表
    @RequestMapping("/index/brand/list")
    public JsonResult<List<BrandStandVO>> getIndexBrandList() {
        return JsonResult.ok(brandMapper.getBrandList());
    }

    //通过品牌id获取品牌信息
    @RequestMapping("/index/brand/list/{id:[1-9]+}")
    public JsonResult<BrandStandVO> getIndexBrandListById(@PathVariable Long id) {
        return JsonResult.ok(brandMapper.getBrandById(id));
    }
}
